home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
drdobbs
/
1991
/
04
/
morrow
/
drive.c
next >
Wrap
C/C++ Source or Header
|
1989-09-03
|
1KB
|
92 lines
/***
* GASystem
* Mike Morrow
* September 1989
***/
/**
* This is the main driver for the GA.
**/
#include <stdio.h>
#include "ga.h"
#include "table.h"
#define PROMPT "\nOK\n"
static void init();
#if __STDC__
static void getstring(char *, unsigned int);
#else
static void getstring();
#endif
main(argc, argv)
int argc;
char *argv[];
{
init();
for(;;)
{
char cmd[80];
getstring(cmd, sizeof cmd - 1);
exec(cmd);
}
}
static void getstring(s, maxlen)
char *s;
unsigned int maxlen;
{
int len;
printf(PROMPT);
fgets(s, maxlen, stdin);
len = strlen(s) - 1;
if(s[len] == '\n')
s[len] = '\0';
}
static void init()
{
#ifdef unix
srandom((unsigned) time((void *) 0));
#else
srand((unsigned) time((void *) 0));
#endif
tbl_init();
/**
* Insert local vars into table.
**/
genepinit();
poplpinit();
exepinit();
/**
* Init. objective function
**/
objinit();
/**
* Init population
**/
poplopen();
}